<template>
  <!-- 承运方管理 -->
  <div class="shareContainer" ref="shareContainer">
    <!-- 内容 -->
    <div class="sharecontent">
      <!-- 头部内容 -->
      <div class="sharecontent_header">
        <div class="sharecontent_header_right">
          <el-button
            v-permission="'company_carrier_create'"
            type="primary"
            plain
            data-tracker="P24-3"
            @click="handleClick(0, '')"
            >新增</el-button
          >
          <el-button
            v-permission="'company_carrier_delete'"
            type="primary"
            plain
            data-tracker="P24-4"
            @click="PagedeleteAccept()"
            >删除</el-button
          >
          <el-button
            type="primary"
            @click="InitiateAudit"
            plain
            data-tracker="P24-4"
            >发起审计</el-button
          >
          <el-button
            type="primary"
            plain
            data-tracker="P24-4"
            @click="trainingprogram"
            >发起培训计划</el-button
          >
          <el-button
            type="primary"
            plain
            data-tracker="P24-4"
            @click="carrierexportObj"
            >导出</el-button
          >
        </div>
        <div class="sharecontent_header_left_left">
          <div>
            <el-button
              type="primary"
              size="mini"
              @click="resetquery"
              style="margin: 0px 10px 0px 0px"
              >重置</el-button
            >
          </div>
          <div>
            <SettinUp
              :settype="31"
              :objSettinUpdata="objSettinUp"
              key="3"
            ></SettinUp>
          </div>
        </div>
      </div>
      <!-- 表单内容 -->
      <div class="sharecontent_content">
        <TableHeader
          ref="TableHeaderList"
          :header_data_list="header_data_list"
          :HeaderData="HeaderData"
          :propMap="propMap"
          :objheader="objheader"
          @childEvent="handleDelete"
          @orderIdNumsEvent="handleDeleteType"
          :operation_type="operation_type"
          @handleClickDetail_second="handleClickDetail_second"
          @handleClickEdit_second="handleClickEdit_second"
          particulars="finance_invoice_book_list"
          redact="finance_invoice_book_update"
          :hasAccountBtn="true"
          @clickGoAccount="clickGoAccount"
        >
        </TableHeader>
        <!-- </el-table> -->
      </div>
      <div class="sharecontent_header_left">
        <el-pagination
          background
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="currentPage4"
          :page-sizes="[10, 20, 30, 40]"
          :page-size="queryparam.page_size"
          layout="total, sizes, prev, pager, next, jumper"
          :total="totalPage"
        >
        </el-pagination>
      </div>
      <!-- 抽屉弹窗 -->
      <div>
        <el-drawer
        :title="title_name"
        :visible.sync="dialogVisible"
        direction="rtl"
        :before-close="handleClose"
        size="50%"
        >
         <div style="background: #F0F2F5;">
          <div style="padding: 10px 0px 0px 0px;">
            <el-form
              :inline="true"
              class="demo-form-inline"
              label-width="120px"
              :model="ruleForm"
              :rules="rules"
              ref="ruleForm"
              :disabled="disableddata"
              label-position="top"
              :key ="this.orderstate"
            >
             <div>
              <el-row :gutter="20" style="padding: 10px; background: #FFFFFF; margin: 0px 10px 10px 10px ;border-radius:5px">
                <el-col :span="8">
                  <el-form-item label="公司名称" prop="name">
                    <el-input
                      placeholder="公司名称"
                      v-model="ruleForm.name"
                    ></el-input> </el-form-item
                ></el-col>
                <el-col :span="16">
                  <el-form-item label="公司地址" prop="setUPvalue">
                    <el-cascader
                      v-model="ruleForm.setUPvalue"
                      placeholder="选择发货地址"
                      :options="AddressBase"
                      :props="{
                        value: 'id',
                        label: 'name',
                        children: 'next_level_data',
                      }"
                    ></el-cascader>
                    <el-input
                      placeholder="公司详细地址"
                      v-model="ruleForm.address"
                      style="width: 208px"
                    >
                    </el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="负责人姓名">
                    <el-input
                      placeholder="负责人姓名"
                      v-model="ruleForm.contact_name"
                    ></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="负责人手机">
                    <el-input
                      placeholder="负责人手机"
                      v-model="ruleForm.contact_mobile"
                    ></el-input>
                  </el-form-item>
                </el-col>

                <el-col :span="8">
                  <el-form-item label="所属组织" prop="branch_id">
                    <el-cascader
                      style="width: 93%"
                      ref="cascader"
                      :options="originList"
                      :show-all-levels="false"
                      placeholder=""
                      v-model="ruleForm.branch_id"
                      :props="{
                        emitPath: false,
                        checkStrictly: true,
                        multiple: true,
                        label: 'branch_name',
                        value: 'id',
                        children: 'next_level_data',
                      }"
                      clearable
                    >
                    </el-cascader>
                  </el-form-item>
                </el-col>
                <el-col :span="8" style="height: 50px">
                  <el-form-item label="承运商编码" prop="coding">
                    <el-input
                      placeholder="承运商编码"
                      v-model="ruleForm.coding"
                    ></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="8" style="height: 50px">
                  <el-form-item label="公司电话">
                    <el-input
                      placeholder="公司电话"
                      v-model="ruleForm.carrier_phone"
                    ></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="社会信用码">
                    <el-input
                      placeholder="社会信用码"
                      v-model="ruleForm.social_credit_code"
                    ></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="审计状态">
                    <el-select
                      v-model="ruleForm.audit_status"
                      disabled
                      placeholder="请选择"
                      style="width: 93%"
                    >
                      <el-option
                        v-for="item in auditStatuslist"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value"
                      >
                      </el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="状态">
                    <el-select
                      style="width: 93%"
                      v-model="ruleForm.status"
                      placeholder="请选择"
                    >
                      <el-option
                        v-for="item in optionsstatus"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value"
                      >
                      </el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="承运大区">
                    <el-select
                      style="width: 93%"
                      v-model="ruleForm.carrier_region"
                      placeholder="请选择"
                    >
                      <el-option
                        v-for="item in Subordinate_list"
                        :key="item.id"
                        :label="item.name"
                        :value="item.id"
                      >
                      </el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="结算方式" >
                    <el-select
                      style="width: 93%"
                      v-model="ruleForm.payment_method"
                      placeholder="请选择"
                    >
                      <el-option
                        key="1"
                        label="现结"
                        value="1"
                      >
                      </el-option>
                      <el-option
                      key="4"
                      label="月结"
                      value="4"
                    >  </el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
                   <!-- 判断 返箱承运商 -->
                <el-col :span="8" >
                  <el-form-item label="描述" >
                    <el-input
                    placeholder="描述"
                    v-model="ruleForm.remark"
                  ></el-input>
                  </el-form-item>
                </el-col>
                <!--  && orderstate != '0' -->
                <el-col :span="8" v-if="ruleForm.carrier_node_type != 0  && orderstate != '0'" style="height: 85px;">
                  <el-form-item label="承运类型">
                   <span>{{ruleForm.carrier_node_type|filterType()}}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="8" class="road_transport_data">
                  <el-form-item label="营业执照">
                    <UploadLink
                      class="business_license"
                      :disabled="disableddata"
                      :files.sync="ruleForm.business_license"
                    ></UploadLink>
                  </el-form-item>
                </el-col>
                <el-col :span="8" class="road_transport_data">
                  <el-form-item label="道路运输许可证">
                    <UploadLink
                      :disabled="disableddata"
                      :files.sync="ruleForm.road_transport_permit"
                      style="width: 200px"
                    ></UploadLink>
                  </el-form-item>
                </el-col>
                <el-col :span="8" class="road_transport_data">
                  <el-form-item label="审计记录表">
                    <UploadLink
                      class="business_license"
                      :disabled="disableddata"
                      :files.sync="ruleForm.audit_record"
                    >
                    </UploadLink>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="审计报告">
                    <UploadLink
                      class="business_license"
                      :disabled="disableddata"
                      :files.sync="ruleForm.audit_report"
                    >
                    </UploadLink>
                  </el-form-item>
                </el-col>
             
              </el-row>
             </div>
             <div style="padding: 10px;background: #FFFFFF; margin: 0px 10px 10px 10px;border-radius:5px">
              <el-row >
                <el-button
                  @click="adduser(0)"
                  type="primary"
                  icon="el-icon-plus"
                  style="margin-bottom: 10px"
                  v-if="orderstate=='0'"
                  >添加账号</el-button
                >
                <div v-for="(itme, index) in ruleForm.account" :key="index">
                  <el-row>
                    <el-col :span="5">
                      <el-form-item label="账号:" >
                        <el-input
                          :disabled="orderstate != 0"
                          v-model.trim="itme.user_name"
                          placeholder="请输入账号"
                        ></el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="5" v-if="orderstate=='0'">
                      <el-form-item label="密码:">
                        <el-input
                        :disabled="orderstate != 0"

                          v-model="itme.password"
                          placeholder="请输入密码"
                        ></el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="5">
                      <el-form-item label="用户名:">
                        <el-input
                        :disabled="orderstate != 0"
                          v-model="itme.nickname"
                          placeholder="请输入用户名"
                        ></el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="5">
                      <el-form-item
                        label="手机号:"
                        :prop="'account.' + index + '.mobile'"
                        :rules="rules.mobile"
                      >
                        <el-input
                          v-model.trim="itme.mobile"
                          placeholder="请输入手机号"
                        ></el-input>
                      </el-form-item>
                    </el-col>
                      <el-col :span="5">
                  <el-form-item  label="数据视野权限类型" :prop="'account.' + index + '.data_view_permission_type'">
                      <el-radio-group @input="handleTypeChange(itme)" v-model="itme.data_view_permission_type">
                        <el-radio label="0">目的网点</el-radio>
                        <el-radio label="1">客户</el-radio>
                      </el-radio-group>
                  </el-form-item>
                  </el-col>
                  <el-col :span="5">
                    <el-form-item v-if="itme.data_view_permission_type == '0'" label="目的网点" :prop="'account.' + index + '.type_ids'">
                      <el-cascader
                        ref="cascader"
                        :options="originList"
                        :show-all-levels="false"
                        placeholder=""
                        v-model="itme.type_ids"
                        :props="{
                          emitPath: false,
                          checkStrictly: true,
                          multiple: true,
                          label: 'branch_name',
                          value: 'id',
                          children: 'next_level_data',
                        }"
                        clearable
                      >
                      </el-cascader>
                    </el-form-item>
                  </el-col>
                  <el-col :span="5">
                    <el-form-item v-if="itme.data_view_permission_type == '1'" label="客户" :prop="'account.' + index + '.type_ids'">
                      <el-select
                        filterable
                        remote
                        multiple
                        reserve-keyword
                        :remote-method="searchCustomerList"
                        v-model="itme.type_ids"
                        style="width: 100%"
                      >
                        <el-option
                          id="customer"
                          v-for="item in clientList"
                          :key="item.id"
                          :label="item.name"
                          :value="item.id"
                        >
                        </el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="2" v-if="ruleForm.account.length > 1">
                    <el-form-item label=" ">
                      <el-button
                        style="margin: 15px 0px 0px 20px"
                        type="primary"
                        icon="el-icon-minus"
                        circle
                        @click="startoff(index, 0)"
                      ></el-button>
                    </el-form-item>
                  </el-col>
                  </el-row>
                </div>
              </el-row>
             </div>
            </el-form>
          </div>
          <div style="padding: 10px;background: #FFFFFF; margin: 0px 10px 10px 10px;border-radius:5px">
            <div style="margin: 0px 0px 10px 0px">
              <el-button plain type="primary" @click="reimbureadd()"
                >新增</el-button
              >
              <el-button plain type="primary" @click="reimburedelet()"
                >删除</el-button
              >
            </div>
            <div>
              <el-table
                :data="ruleForm.electronic_contract"
                border
                style="width: 100%"
                @selection-change="tableRowClassName"
              >
                <el-table-column type="selection" width="45"> </el-table-column>
                <el-table-column
                  prop="contract_name"
                  label="合同名称"
                  width="180"
                >
                  <template slot-scope="scope">
                    <el-input
                      v-model="scope.row.contract_name"
                      :disabled="disableddata"
                    ></el-input>
                  </template>
                </el-table-column>
                <el-table-column
                  prop="signing_time"
                  label="签约时间"
                  width="210"
                >
                  <template slot-scope="scope">
                    <el-date-picker
                      :disabled="disableddata"
                      style="width: 185px"
                      v-model="scope.row.signing_time"
                      type="datetime"
                      value-format="timestamp"
                      placeholder="选择日期时间"
                      default-time="12:00:00"
                      :default-value="new Date()"
                    >
                    </el-date-picker>
                  </template>
                </el-table-column>
                <el-table-column
                  prop="start_time_of_contract"
                  label="合同起始时间"
                  width="210"
                >
                  <template slot-scope="scope">
                    <el-date-picker
                      :disabled="disableddata"
                      style="width: 185px"
                      v-model="scope.row.start_time_of_contract"
                      type="datetime"
                      value-format="timestamp"
                      placeholder="选择日期时间"
                      default-time="12:00:00"
                      :default-value="new Date()"
                    >
                    </el-date-picker>
                  </template>
                </el-table-column>
                <el-table-column
                  prop="end_time_of_contract"
                  label="合同结束时间"
                  width="210"
                >
                  <template slot-scope="scope">
                    <el-date-picker
                      :disabled="disableddata"
                      style="width: 185px"
                      v-model="scope.row.end_time_of_contract"
                      type="datetime"
                      value-format="timestamp"
                      placeholder="选择日期时间"
                      default-time="12:00:00"
                      :default-value="new Date()"
                    >
                    </el-date-picker>
                  </template>
                </el-table-column>
                <el-table-column property="contract_file_list" label="上传合同">
                  <template slot-scope="scope">
                    <UploadLink
                      :disabled="disableddata"
                      :files.sync="scope.row.contract_file_list"
                    ></UploadLink>
                  </template>
                </el-table-column>
              </el-table>
            </div>
          </div>
          <div style="text-align: center; margin:0px 0px 10px 0px; padding-bottom: 10px; ">
            <el-button
            :data-tracker="orderstate == '0' ? 'P24-8' : 'P24-10'"
            @click="cancledata()"
            >取 消</el-button
          >
          <el-button
            type="primary"
            data-tracker="P24-7"
            @click="PageAddAccept('ruleForm')"
            v-if="orderstate == '0'"
            >确 定
          </el-button>
          <el-button
            type="primary"
            data-tracker="P24-9"
            @click="PageEditAccept('ruleForm')"
            v-if="orderstate == '2' || orderstate == '4'"
            >确 定
          </el-button>
          </div>
          <!-- <span slot="footer" style="padding: 10px; margin: 0px 0px 10px 0px;">
           
          </span> -->
         </div>
      </el-drawer>
      </div>
      <!-- 弹框内容 -->
      <!-- <div>
        <el-dialog
          :title="title_name"
          :close-on-click-modal="false"
          :visible.sync="dialogVisible"
          width="80%"
          :before-close="handleClose"
        >
          <div>
            <el-form
              :inline="true"
              class="demo-form-inline"
              label-width="120px"
              :model="ruleForm"
              :rules="rules"
              ref="ruleForm"
              :disabled="disableddata"
              label-position="top"
            >
              <el-row :gutter="20">
                <el-col :span="8">
                  <el-form-item label="公司名称" prop="name">
                    <el-input
                      placeholder="公司名称"
                      v-model="ruleForm.name"
                    ></el-input> </el-form-item
                ></el-col>
                <el-col :span="16">
                  <el-form-item label="公司地址">
                    <el-cascader
                      v-model="ruleForm.setUPvalue"
                      placeholder="选择发货地址"
                      :options="AddressBase"
                      :props="{
                        value: 'id',
                        label: 'name',
                        children: 'next_level_data',
                      }"
                    ></el-cascader>
                    <el-input
                      placeholder="公司详细地址"
                      v-model="ruleForm.address"
                      style="width: 208px"
                    >
                    </el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="负责人姓名">
                    <el-input
                      placeholder="负责人姓名"
                      v-model="ruleForm.contact_name"
                    ></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="负责人手机">
                    <el-input
                      placeholder="负责人手机"
                      v-model="ruleForm.contact_mobile"
                    ></el-input>
                  </el-form-item>
                </el-col>

                <el-col :span="8">
                  <el-form-item label="所属组织" prop="branch_id">
                    <el-cascader
                      style="width: 93%"
                      ref="cascader"
                      :options="originList"
                      :show-all-levels="false"
                      placeholder=""
                      v-model="ruleForm.branch_id"
                      :props="{
                        emitPath: false,
                        checkStrictly: true,
                        multiple: true,
                        label: 'branch_name',
                        value: 'id',
                        children: 'next_level_data',
                      }"
                      clearable
                    >
                    </el-cascader>
                  </el-form-item>
                </el-col>
                <el-col :span="8" style="height: 50px">
                  <el-form-item label="承运商编码" prop="coding">
                    <el-input
                      placeholder="承运商编码"
                      v-model="ruleForm.coding"
                    ></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="8" style="height: 50px">
                  <el-form-item label="公司电话">
                    <el-input
                      placeholder="公司电话"
                      v-model="ruleForm.carrier_phone"
                    ></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="社会信用码">
                    <el-input
                      placeholder="社会信用码"
                      v-model="ruleForm.social_credit_code"
                    ></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="审计状态">
                    <el-select
                      v-model="ruleForm.audit_status"
                      disabled
                      placeholder="请选择"
                      style="width: 93%"
                    >
                      <el-option
                        v-for="item in auditStatuslist"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value"
                      >
                      </el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="状态">
                    <el-select
                      style="width: 93%"
                      v-model="ruleForm.status"
                      placeholder="请选择"
                    >
                      <el-option
                        v-for="item in optionsstatus"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value"
                      >
                      </el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="承运大区">
                    <el-select
                      style="width: 93%"
                      v-model="ruleForm.carrier_region"
                      placeholder="请选择"
                    >
                      <el-option
                        v-for="item in Subordinate_list"
                        :key="item.id"
                        :label="item.name"
                        :value="item.id"
                      >
                      </el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="8" class="road_transport_data">
                  <el-form-item label="营业执照">
                    <UploadLink
                      class="business_license"
                      :disabled="disableddata"
                      :files.sync="ruleForm.business_license"
                    ></UploadLink>
                  </el-form-item>
                </el-col>
                <el-col :span="8" class="road_transport_data">
                  <el-form-item label="道路运输许可证">
                    <UploadLink
                      :disabled="disableddata"
                      :files.sync="ruleForm.road_transport_permit"
                      style="width: 200px"
                    ></UploadLink>
                  </el-form-item>
                </el-col>
                <el-col :span="8" class="road_transport_data">
                  <el-form-item label="审计记录表">
                    <UploadLink
                      class="business_license"
                      :disabled="disableddata"
                      :files.sync="ruleForm.audit_record"
                    >
                    </UploadLink>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="审计报告">
                    <UploadLink
                      class="business_license"
                      :disabled="disableddata"
                      :files.sync="ruleForm.audit_report"
                    >
                    </UploadLink>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row v-if="orderstate == 0">
                <el-button
                  @click="adduser(0)"
                  type="primary"
                  icon="el-icon-plus"
                  style="margin-bottom: 10px"
                  >添加账号</el-button
                >
                <div v-for="(itme, index) in ruleForm.account" :key="index">
                  <el-row>
                    <el-col :span="5">
                      <el-form-item label="账号:">
                        <el-input
                          v-model.trim="itme.user_name"
                          placeholder="请输入账号"
                        ></el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="5">
                      <el-form-item label="密码:">
                        <el-input
                          v-model="itme.password"
                          placeholder="请输入密码"
                        ></el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="5">
                      <el-form-item label="用户名:">
                        <el-input
                          v-model="itme.nickname"
                          placeholder="请输入用户名"
                        ></el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="5">
                      <el-form-item
                        label="手机号:"
                        :prop="'account.' + index + '.mobile'"
                        :rules="rules.mobile"
                      >
                        <el-input
                          v-model.trim="itme.mobile"
                          placeholder="请输入手机号"
                        ></el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="2" v-if="ruleForm.account.length > 1">
                      <el-form-item label=" ">
                        <el-button
                          style="margin: 20px 0px 0px 0px"
                          type="primary"
                          icon="el-icon-minus"
                          circle
                          @click="startoff(index, 0)"
                        ></el-button>
                      </el-form-item>
                    </el-col>
                  </el-row>
                </div>
              </el-row>
            </el-form>
          </div>
          <div>
            <div style="margin: 0px 0px 10px 0px">
              <el-button plain type="primary" @click="reimbureadd()"
                >新增</el-button
              >
              <el-button plain type="primary" @click="reimburedelet()"
                >删除</el-button
              >
            </div>
            <div>
              <el-table
                :data="ruleForm.electronic_contract"
                border
                style="width: 100%"
                @selection-change="tableRowClassName"
              >
                <el-table-column type="selection" width="45"> </el-table-column>
                <el-table-column
                  prop="contract_name"
                  label="合同名称"
                  width="180"
                >
                  <template slot-scope="scope">
                    <el-input
                      v-model="scope.row.contract_name"
                      :disabled="disableddata"
                    ></el-input>
                  </template>
                </el-table-column>
                <el-table-column
                  prop="signing_time"
                  label="签约时间"
                  width="210"
                >
                  <template slot-scope="scope">
                    <el-date-picker
                      :disabled="disableddata"
                      style="width: 185px"
                      v-model="scope.row.signing_time"
                      type="datetime"
                      value-format="timestamp"
                      placeholder="选择日期时间"
                      default-time="12:00:00"
                      :default-value="new Date()"
                    >
                    </el-date-picker>
                  </template>
                </el-table-column>
                <el-table-column
                  prop="start_time_of_contract"
                  label="合同起始时间"
                  width="210"
                >
                  <template slot-scope="scope">
                    <el-date-picker
                      :disabled="disableddata"
                      style="width: 185px"
                      v-model="scope.row.start_time_of_contract"
                      type="datetime"
                      value-format="timestamp"
                      placeholder="选择日期时间"
                      default-time="12:00:00"
                      :default-value="new Date()"
                    >
                    </el-date-picker>
                  </template>
                </el-table-column>
                <el-table-column
                  prop="end_time_of_contract"
                  label="合同结束时间"
                  width="210"
                >
                  <template slot-scope="scope">
                    <el-date-picker
                      :disabled="disableddata"
                      style="width: 185px"
                      v-model="scope.row.end_time_of_contract"
                      type="datetime"
                      value-format="timestamp"
                      placeholder="选择日期时间"
                      default-time="12:00:00"
                      :default-value="new Date()"
                    >
                    </el-date-picker>
                  </template>
                </el-table-column>
                <el-table-column property="contract_file_list" label="上传合同">
                  <template slot-scope="scope">
                    <UploadLink
                      :disabled="disableddata"
                      :files.sync="scope.row.contract_file_list"
                    ></UploadLink>
                  </template>
                </el-table-column>
              </el-table>
            </div>
          </div>
          <span slot="footer" class="dialog-footer">
            <el-button
              :data-tracker="orderstate == '0' ? 'P24-8' : 'P24-10'"
              @click="cancledata()"
              >取 消</el-button
            >
            <el-button
              type="primary"
              data-tracker="P24-7"
              @click="PageAddAccept('ruleForm')"
              v-if="orderstate == '0'"
              >确 定
            </el-button>
            <el-button
              type="primary"
              data-tracker="P24-9"
              @click="PageEditAccept('ruleForm')"
              v-if="orderstate == '2'"
              >确 定
            </el-button>
          </span>
        </el-dialog>
      </div> -->
    </div>
  </div>
</template>

<script>
import TableHeader from "@/page/orderform/components/TableHeader/tableheader.vue";
import SettinUp from "@/page/orderform/components/settingUp/settingUp.vue";
import {
  Acceptlist,
  AddAccept,
  EditAccept,
  DetailsAccept,
  deleteAccept,
  carrierexport,
} from "@/api/information";
import {
  uploading,
  PagewebsiteList,
  regionList,
  dictionanry,
} from "../common/common";
import { timestamp10 } from "@/utils/mUtils";
import { organizationBox, branchList, UserCount } from "@/api/organization";
import UploadLink from "@/components/uploadFile/uploadLink.vue";
import md5 from "js-md5";
import { customerPeople } from "@/api/information";

export default {
  components: { TableHeader, SettinUp, UploadLink },
  data() {
    return {
      title_name: "承运商",
      inputname: "", //输入公司名称
      queryvalue: [], //公司地址
      detailvalue: "", //公司详细地址
      AddressBase: [], //地址库接口
      originList: [], //组织
      queryparam: {
        page: 1,
        page_size: 20,
      }, //发货方搜索接口
      // 分页功能
      total: 0, //总条数
      currentPage4: 1,
      deletparam: {
        id: [], //多选删的id
      },
      ruleForm: {
        name: "", // 名称 必传
        contact_name: "", //负责人姓名
        contact_mobile: "", //负责人手机
        contact_phone: "", //公司电话电话
        coding: "", //承运商编码  必传
        business_license: [], //营业执照
        road_transport_permit: [], //道路运输许可证
        audit_report: [], //审计报告
        audit_record: [], //审计记录表
        setUPvalue: [], //地址
        carrier_type: "1", //类型：0自营，1其他    必传
        address: "", //详细地址
        branch_id: "", //网点id ，类型为自营时 必填
        remark: "", //描述信息
        // 新增的内容 ========
        carrier_phone: "", //公司电话
        electronic_contract: [
          {
            id: "1",
            contract_name: "", // 合同名
            contract_file: "", // 合同路径
            signing_time: "", // 签约时间
            start_time_of_contract: "", // 合同起始时间
            end_time_of_contract: "", //合同结束时间
            contract_file_list: [], //上传的文件
          },
        ], // 电子合同,// 电子合同
        // certification: ["资质"],// 资质(暂时不需要)
        social_credit_code: "", // 社会信用码
        audit_status: 0, // 审计状态：0待审计,1生效,2驳回
        status: 0, // 状态0-启用，1-停用，2-黑名单
        carrier_region: "", // 承运大区
        account: [
          {
            user_name: "", // 账号
            password: "", // 密码
            mobile: "", //手机号
            nickname: "", // 昵称
            data_view_permission_type:"0",
            type_ids:[]
          },
        ],
        payment_method:"4",
      },
      rules: {
        name: [{ required: true, message: "请填写公司名称", trigger: "blur" }],
        coding: [
          { required: true, message: "请输入承运商编码", trigger: "blur" },
        ],
        carrier_type: [
          { required: true, message: "请输入承运商类型", trigger: "blur" },
        ],
        branch_id: [{ required: true, message: "请输入网点", trigger: "change" }],
        user_name: [
          { required: true, message: "请输入用户名", trigger: "blur" },
          {
            validator: this.checkUser,
            trigger: "blur",
          },
        ],
        password: [{ required: true, message: "请输入密码", trigger: "blur" }],
        setUPvalue: [{ required: true, message: "请输入公司地址", trigger: "blur" }],
        address: [{ required: true, message: "公司详细地址", trigger: "blur" }],
      },
      tableData: [],
      orderstate: "", //新增状态0 编辑状态2
      dialogVisible: false, //判断弹框显示隐藏
      consignerID: "", //发货人的ID
      options: [],
      optionsstatus: [
        {
          value: 0,
          label: "启用",
        },
        {
          value: 1,
          label: "停用",
        },
        {
          value: 2,
          label: "黑名单",
        },
      ],
      auditStatuslist: [
        {
          value: 0,
          label: "待审计",
        },
        {
          value: 1,
          label: "生效",
        },
        {
          value: 2,
          label: "驳回",
        },
      ],
      Subordinate_list: [], //所属的区域
      checkedID: [],
      header_data_list: [],
      propMap: {},
      obj_list: {},
      HeaderData: [],
      waybillIdNums: [],
      totalPage: 0,
      operation_type: 1,
      disableddata: false,
      clientList:[]
      // maxheight:400,
    };
  },

  mounted() {
    // 获取承运商列表
    this.PageAcceptlist();
    // 获取地址库接口
    this.provincectiy();
    // 获取组织接口
    this.siteList();
    // 数据字典
    this.dicList();
  },
  filters: {
    filterType(type) {
      switch (type) {
        case "1":
          return "揽收承运商";
          break;
        case "2":
          return "干线承运商";
          break;
        case "3":
          return "配送承运商";
          break;
        case "4":
          return "回单承运商";
          break
        case "5":
          return "回箱承运商";
          break
        default:
          return "";
      }
    },
   
  },
  methods: {
    handleTypeChange(item){
      item.type_ids=[]
    },
    //获取所属客户
    searchCustomerList(query) {
      //获取客户
      if (query !== "") {
        setTimeout(async () => {
          let result = await customerPeople({
            name: query, // 名称
            id: "",
            is_send: "1",
            is_receive: "",
          });
          if (result.data.length > 0) {
            this.clientList = result.data;
          } else {
            this.clientList = [];
          }
        }, 200);
      } else {
        this.clientList = [];
      }
    },
    async initCustomerList(ids) {
      //获取客户
          let result = await customerPeople({
            ids: ids,
            is_send: "1",
            is_receive: "",
          });
          if (result.data.length > 0) {
            this.clientList = result.data;
          } else {
            this.clientList = [];
          }
  
    
    },
    clickGoAccount(row) {
      this.$router.push({
        name: "invoicebook",
        query: {
          activeName: "2",
          name: row.name,
        },
      });
    },
    // 数据字典
    dicList() {
      //承运商类型
      dictionanry("carrier_type").then((res) => {
        var res = res.data;
        res.list.forEach((item, i) => {
          res.list[i] = { value: item.item_code, label: item.item_name };
        });
        this.options = res.list;
      });
    },
    // 组织管理页面
    siteList() {
      organizationBox({ not_show_first_branch: 1 }).then((res) => {
        this.originList = res.data;
      });
      // 承运大区
      var param = {
        branch_type: "3",
        name: "",
      };
      branchList(param).then((res) => {
        this.Subordinate_list = res.data || {};
      });
    },
    // 地址库
    provincectiy() {
      regionList(0).then((res) => {
        this.AddressBase = res.data;
      });
    },
    // 一页有多少条
    handleSizeChange(val) {
      this.queryparam.page_size = val;
      //  数据列表接口
      this.PageAcceptlist();
    },
    // 当前第几页
    handleCurrentChange(val) {
      this.queryparam.page = val;
      //  数据列表接口
      this.PageAcceptlist();
    },
    // 点击关闭需要调用的函数
    handleClose() {
      this.Empty_data();
      this.closepop();
    },
    // 承运方列表
    PageAcceptlist() {
      var param = {
        ...this.queryparam,
        header_id: 31 + "",
        ...this.obj_list,
      };
      Acceptlist(param).then((res) => {
        this.orders = res.data.list || [];
        this.orders.unshift({});
        this.header_data_list = this.orders;
        this.HeaderData = res.data.item_list;
        this.Fntransformation(this.HeaderData);
        this.totalPage = res.data.pagination.total;
      });
    },

    objheader(obj) {
      var data = {
        header_id: 31 + "",
        ...obj,
        carrier_region: obj.carrier_region * 1,
      };
      this.obj_list = obj;
      Acceptlist(data).then((res) => {
        this.header_data_list = res.data.list;
        if (res.code === 10000 && res.data.list !== null) {
          this.header_data_list.unshift({});
          this.totalPage = res.data.pagination.total;
          // console.log(res.data.pagination, "res.data.pagination");
          this.queryparam.page_size = 20;
        } else {
          this.header_data_list = [{}];
          this.totalPag = 0;
          this.orderslength = 0;
          this.totalPage = res.data.pagination.total;
        }
      });
    },
    Fntransformation(obj) {
      const result = {};
      for (const prop in obj) {
        if (obj.hasOwnProperty(prop)) {
          if (obj[prop].send_name !== "") {
            result[obj[prop].name] = obj[prop].show_name;
          } else {
            result[obj[prop].name] = obj[prop].name;
          }
        }
      }
      this.propMap = result;
    },
    handleDelete(index, id, type) {
      this.handleJumpDetail(id);
    },
    handleDeleteType(value) {
      this.waybillIdNums = value;
    },
    // ===============
    // 处理列表的数据
    // DataState(res) {
    //   var nametable = [];
    //   for (var i = 0; i < res.length; i++) {
    //     let branch_name_list = [];
    //     if (res[i].branch_info != null) {
    //       for (var j = 0; j < res[i].branch_info.length; j++) {
    //         branch_name_list.push(res[i].branch_info[j].branch_name + "/");
    //       }
    //     }
    //     var type = res[i].carrier_type === "0" ? "自营承运商" : "物流承运商";
    //     nametable.push({
    //       id: res[i].id,
    //       name: res[i].name, //公司名字
    //       contact_name: res[i].contact_name, //负责人名字
    //       contact_mobile: res[i].contact_mobile, //负责人手机号
    //       contact_phone: res[i].contact_phone, //公司电话
    //       coding: res[i].coding, //承运商编码
    //       business_license: res[i].business_license, //营业执照
    //       road_transport_permit: res[i].road_transport_permit, //道路运输许可证
    //       audit_report: res[i].audit_report, //审计报告
    //       audit_record: res[i].audit_record, //审计记录表
    //       carrier_type: type, //类型
    //       province:
    //         res[i].province_name +
    //         "/" +
    //         res[i].city_name +
    //         "/" +
    //         res[i].district_name +
    //         "/" +
    //         res[i].address,
    //       remark: res[i].remark, //描述信息
    //       branch_name: branch_name_list, //网点名字
    //     });
    //   }
    //   this.tableData = nametable;
    // },
    // 创建承运方
    PageAddAccept(formName) {
      console.log(formName,"PageAddAcceptPageAddAccept")
      this.$refs[formName].validate((valid) => {
        if (valid) {
          // 营业执照
          var license =
            this.ruleForm.business_license.length == 0
              ? ""
              : this.ruleForm.business_license[0].url;

          var permit =
            this.ruleForm.road_transport_permit.length == 0
              ? ""
              : this.ruleForm.road_transport_permit[0].url;

          var record = [];
          if (this.ruleForm.audit_record.length == 0) {
            record = [];
          } else {
            for (var i = 0; i < this.ruleForm.audit_record.length; i++) {
              record.push(this.ruleForm.audit_record[i].url);
            }
          }
          var report = [];
          if (this.ruleForm.audit_report.length == 0) {
            report = [];
          } else {
            for (var i = 0; i < this.ruleForm.audit_report.length; i++) {
              report.push(this.ruleForm.audit_report[i].url);
            }
          }
          var assignContractFile_list = this.assignContractFile(
            this.ruleForm.electronic_contract
          );
          var accountpassword = JSON.parse(
            JSON.stringify(this.ruleForm.account)
          );
          accountpassword.find((item) => (item.password = md5(item.password)));
          var parme = {
            ...this.ruleForm,
            name: this.ruleForm.name, //名称 必传
            contact_name: this.ruleForm.contact_name, //负责人姓名
            contact_mobile: this.ruleForm.contact_mobile, //负责人手机
            contact_phone: this.ruleForm.contact_phone, //电话
            coding: this.ruleForm.coding, // 承运商编码  必传
            business_license: license, // 营业执照
            road_transport_permit: permit, // 道路运输许可证
            audit_report: report, // 审计报告
            audit_record: record, //审计记录表
            province_id: this.ruleForm.setUPvalue[0], //省id
            city_id: this.ruleForm.setUPvalue[1], //市id
            district_id: this.ruleForm.setUPvalue[2], //区id
            carrier_type: this.ruleForm.carrier_type, //类型：0自营，1其他    必传
            address: this.ruleForm.address, //详细地址
            branch_id: this.ruleForm.branch_id, //网点id ，类型为自营时 必填
            // remark: this.ruleForm.remark, //描述信息.
            carrier_region:
              this.ruleForm.carrier_region == ""
                ? 0
                : this.ruleForm.carrier_region,
            electronic_contract: assignContractFile_list,
            account: accountpassword,
          };
          AddAccept(parme).then((res) => {
            if (res.code == 10000) {
              this.$message({
                message: "创建承运商成功",
                type: "success",
              });
              // this.message();
              this.closepop();
              this.PageAcceptlist();
            }
          });
        } else {
          // console.log("error submit!!");
          return false;
        }
      });
    },
    // 编辑承运方
    PageEditAccept(formName) {
    
      this.$refs[formName].validate((valid) => {
        if (valid) {
          if(this.ruleForm.setUPvalue.every(item => item == 0)) {
              this.$message({
              message: '请输入公司地址',
              type: 'warning'
            });
          }else {
            var license =
            this.ruleForm.business_license.length == 0
              ? ""
              : this.ruleForm.business_license[0].url;
          var permit =
            this.ruleForm.road_transport_permit.length == 0
              ? ""
              : this.ruleForm.road_transport_permit[0].url;
          var record = [];
          if (this.ruleForm.audit_record.length == 0) {
            record = [];
          } else {
            for (var i = 0; i < this.ruleForm.audit_record.length; i++) {
              record.push(String(this.ruleForm.audit_record[i].url));
            }
          }
          var report = [];

          if (this.ruleForm.audit_report.length == 0) {
            report = [];
          } else {
            for (var i = 0; i < this.ruleForm.audit_report.length; i++) {
              report.push(String(this.ruleForm.audit_report[i].url));
            }
          }
          // 从新定义一个变量当当回显的上传列表数据为空的时候上传的是fileuidList否则的话
          var assignContractFile_list = this.assignContractFile(
            this.ruleForm.electronic_contract
          );
          var parme = {
            id: this.consignerID,
            ...this.ruleForm,
            name: this.ruleForm.name,
            contact_name: this.ruleForm.contact_name,
            contact_mobile: this.ruleForm.contact_mobile,
            contact_phone: this.ruleForm.contact_phone,
            coding: this.ruleForm.coding,
            business_license: String(license),
            road_transport_permit: String(permit),
            audit_report: report,
            audit_record: record,
            province_id: this.ruleForm.setUPvalue[0],
            city_id: this.ruleForm.setUPvalue[1],
            district_id: this.ruleForm.setUPvalue[2],
            carrier_type: this.ruleForm.carrier_type,
            address: this.ruleForm.address,
            branch_id: this.ruleForm.branch_id,
            carrier_region:
              this.ruleForm.carrier_region == ""
                ? 0
                : this.ruleForm.carrier_region,
            // remark: this.ruleForm.remark, //描述信息
            electronic_contract: assignContractFile_list,
          };
          EditAccept(parme).then((res) => {
            if (res.code == 10000) {
              this.$message({
                message: "编辑成功",
                type: "success",
              });
              this.closepop();
              // 刷新界面
              this.PageAcceptlist();
            }
          });
          }
         
        } else {
          // console.log("error submit!!");
          return false;
        }
      });
    },
    // 获取多选删除的id号
    handleSelectionChange(val) {
      var deleid = [];
      for (var i = 0; i < val.length; i++) {
        deleid.push(val[i].id);
      }
      this.deletparam.id = deleid;
    },
    // 删除承运方
    PagedeleteAccept() {
      var param = {
        id: this.waybillIdNums.map(Number),
      };
      deleteAccept(param).then((res) => {
        this.$message({
          message: "删除成功",
          type: "success",
        });
        // 关闭页面
        this.closepop();
        // 刷新界面
        this.PageAcceptlist();
      });
    },
    //修改
    handleClick(type, id) {
      if (type == 0) {
        this.title_name = "创建承运商";
        this.orderstate = "0";
        this.disableddata = false;
        // this.Empty_data();
        this.openpop();
      } else if (type == 1) {
        this.title_name = "承运商详情";
        this.orderstate = "";
        this.disableddata = true;
        this.openpop();
        this.PageDetailsshipping(id);
      } else if (type == 2) {
        this.title_name = "修改承运商";
        this.orderstate = "2";
        this.disableddata = false;
        this.consignerID = id;
        this.openpop();
        this.PageDetailsshipping(id);
      }
    },
    // 承运方详情详情
    PageDetailsshipping(id) {
      var params = {
        id: id,
      };
      DetailsAccept(params).then((res) => {
        var res = res.data;
        this.ruleForm = { ...res };
        var license = [];
        if (res.business_license == "") {
          license = [];
        } else {
          license.push({
            name: res.business_license,
            url: res.business_license,
          });
        }
        var permit = [];
        if (res.road_transport_permit == "") {
          permit = [];
        } else {
          permit.push({
            name: res.road_transport_permit,
            url: res.business_license,
          });
        }
        var record = [];
        if (res.audit_record == null) {
          record = [];
        } else {
          for (var i = 0; i < res.audit_record.length; i++) {
            record.push({
              name: [res.audit_record[i]],
              url: [res.audit_record[i]],
            });
          }
        }
        var report = [];
        if (res.audit_report == null) {
          report = [];
        } else {
          for (var i = 0; i < res.audit_report.length; i++) {
            report.push({
              name: [res.audit_report[i]],
              url: [res.audit_report[i]],
            });
          }
        }
        this.ruleForm.name = res.name;
        this.ruleForm.setUPvalue = [
          res.province_id,
          res.city_id,
          res.district_id,
        ]; //地址
        // 组织
        var branchList = [];
        res.branch_info.forEach((res) => {
          branchList.push(res.branch_id);
        });
        var edit_series = this.addContractToFileList(res.electronic_contract);

        this.ruleForm.contact_name = res.contact_name; //负责人姓名
        // this.ruleForm.contact_mobile = res.contact_mobile; //负责人手机
        // this.ruleForm.contact_phone = res.contact_phone; //公司电话电话
        // this.ruleForm.coding = res.coding; //承运商编码  必传
        this.ruleForm.business_license = license; //营业执照
        this.ruleForm.road_transport_permit = permit; //道路运输许可证
        this.ruleForm.audit_report = report; //审计报告
        this.ruleForm.audit_record = record; //审计记录表
        // this.ruleForm.carrier_type = res.carrier_type; //类型：0自营，1其他    必传
        // this.ruleForm.address = res.address; //详细地址
        this.ruleForm.branch_id = branchList; //网点id ，类型为自营时 必填
        // this.ruleForm.remark = res.remark; //描述信息
        this.ruleForm.carrier_region =
          res.carrier_region == 0 ? "" : res.carrier_region;
        this.ruleForm.electronic_contract = edit_series;
        let ids=[]
        this.ruleForm.account.forEach(item=>{
          if(item.data_view_permission_type=='1'){
            ids.push(...item.type_ids)
          }
        })
        if(ids.length>0){
          this.initCustomerList(ids)
        }
      });
    },
    // 上传到oss上
    handleChange(file, fileList, type) {
      var filelist = file.raw; //文件
      var filename = file.raw.uid + file.raw.name; //通过 uid和name组成文件的名字
      uploading(filelist, filename, type).then((result) => {
        var resname = result.name;
        var resType = resname.split("/")[0];
        var filehttp = "http://oss.dushisc.com/";
        switch (resType) {
          case "0":
            this.ruleForm.business_license.push({
              name: filehttp + result.name,
            });
            break;
          case "1":
            this.ruleForm.road_transport_permit.push({
              name: filehttp + result.name,
            });
            break;
          case "2":
            this.ruleForm.audit_record.push({ name: filehttp + result.name });
            break;
          case "3":
            this.ruleForm.audit_report.push({ name: filehttp + result.name });
            break;
        }
      });
    },
    // 点击取消
    cancledata() {
      // 清空数据
      this.Empty_data();
      this.closepop();
    },
    // 关闭弹框的函数
    closepop() {
      this.dialogVisible = false;
    },
    openpop() {
      this.dialogVisible = true;
    },

    // 删除调用
    removeChange(file, fileList, type) {
      switch (type) {
        case 0:
          if (this.ruleForm.business_license.length > 0) {
            for (var i = 0; i < this.ruleForm.business_license.length; i++) {
              if (this.ruleForm.business_license[i].uid == file.uid) {
                this.ruleForm.business_license.splice(i, 1);
              }
            }
          }
          break;
        case 1:
          if (this.ruleForm.road_transport_permit.length > 0) {
            for (
              var i = 0;
              i < this.ruleForm.road_transport_permit.length;
              i++
            ) {
              if (this.ruleForm.road_transport_permit[i].uid == file.uid) {
                this.ruleForm.road_transport_permit.splice(i, 1);
              }
            }
          }
          break;
        case 2:
          if (this.ruleForm.audit_record.length > 0) {
            for (var i = 0; i < this.ruleForm.audit_record.length; i++) {
              if (this.ruleForm.audit_record[i].uid == file.uid) {
                this.ruleForm.audit_record.splice(i, 1);
              }
            }
          }
          break;
        case 3:
          if (this.ruleForm.audit_report.length > 0) {
            for (var i = 0; i < this.ruleForm.audit_report.length; i++) {
              if (this.ruleForm.audit_report[i].uid == file.uid) {
                this.ruleForm.audit_report.splice(i, 1);
              }
            }
          }
          break;
      }
    },
    // 清空数据
    Empty_data() {
      Object.assign(this.$data.ruleForm, this.$options.data().ruleForm);
    },
    // 重置数据
    resetquery() {
      // 查询数据清除

      this.$refs.TableHeaderList.childMethod();
    },
    objSettinUp() {
      this.PageAcceptlist();
    },
    // 上传
    handleChangetwo(file, fileList, index) {
      var filelist = file.raw; //文件
      var filename = file.raw.uid + file.raw.name; //通过 uid和name组成文件的名字
      uploading(filelist, filename, 30).then((result) => {
        var resname = result.name;
        this.ImportDataUrl = resname;
        var filehttp = "http://oss.dushisc.com/";
        this.ruleForm.electronic_contract[index].contract_file_list.push({
          name: filehttp + result.name,
          url: filehttp + result.name,
        });
      });
    },
    removeChangetwo(file, index) {
      if (
        this.ruleForm.electronic_contract[index].contract_file_list.length > 0
      ) {
        for (
          var i = 0;
          i <
          this.ruleForm.electronic_contract[index].contract_file_list.length;
          i++
        ) {
          if (
            this.ruleForm.electronic_contract[index].contract_file_list[i]
              .uid == file.uid
          ) {
            this.ruleForm.electronic_contract[index].contract_file_list.splice(
              i,
              1
            );
          }
        }
      }
    },
    reimbureadd() {
      var id_length = this.ruleForm.electronic_contract.length + 1;
      this.ruleForm.electronic_contract.push({
        id: "",
        contract_name: "", // 合同名
        contract_file: "", // 合同路径
        signing_time: "", // 签约时间
        start_time_of_contract: "", // 合同起始时间
        end_time_of_contract: "", //合同结束时间
        contract_file_list: [], //上传的文件
      });
    },
    reimburedelet() {
      this.ruleForm.electronic_contract.forEach((v, i) => {
        this.checkedID.forEach((val, index) => {
          if (val == v.id) {
            this.ruleForm.electronic_contract.splice(i, 1);
          }
        });
      });
    },
    tableRowClassName(val) {
      var deleid = [];
      for (var i = 0; i < val.length; i++) {
        deleid.push(val[i].id);
      }
      this.checkedID = deleid;
    },
    // 创建的时候处理列表的数据
    assignContractFile(data) {
      for (let i = 0; i < data.length; i++) {
        const contract = data[i];
        contract.contract_file =
          contract.contract_file_list.length == 0
            ? ""
            : contract.contract_file_list[0].url;
        contract.signing_time =
          contract.signing_time == ""
            ? 0
            : timestamp10(contract.signing_time) * 1;
        contract.start_time_of_contract =
          contract.start_time_of_contract == ""
            ? 0
            : timestamp10(contract.start_time_of_contract) * 1;
        contract.end_time_of_contract =
          contract.end_time_of_contract == ""
            ? 0
            : timestamp10(contract.end_time_of_contract) * 1;
      }
      return data;
    },
    // 编辑的时候处理数据
    addContractToFileList(contractList) {
      const updatedContractList = contractList.map((contract) => {
        contract.contract_file_list =
          contract.contract_file == ""
            ? ""
            : [{ name: contract.contract_file, url: contract.contract_file }];
        contract.signing_time =
          contract.signing_time * 1 == 0 ? "" : contract.signing_time * 1000;
        contract.end_time_of_contract =
          contract.end_time_of_contract * 1 == 0
            ? ""
            : contract.end_time_of_contract * 1000;
        contract.start_time_of_contract =
          contract.start_time_of_contract * 1 == 0
            ? ""
            : contract.start_time_of_contract * 1000;
        return contract;
      });

      return updatedContractList;
    },
    handleClickDetail_second(val) {
      this.handleClick(1, val.id);
    },
    handleClickEdit_second(val) {
      this.handleClick(2, val.id);
    },
    carrierexportObj() {
      var param = {
        ...this.obj_list,
        create_time: [],
        ids: this.waybillIdNums.map(Number),
        // header_id: 31,
      };
      carrierexport(param).then((res) => {
        if (res.code === 10000) {
          const linkurl = "https://" + res.data.data;
          window.open(linkurl);
        }
      });
    },
    trainingprogram() {
      if (this.waybillIdNums.length > 0) {
        this.$router.push({
          name: "train",
          query: { type: "4", id: this.waybillIdNums },
        });
      } else {
      }
    },
    InitiateAudit() {
      if (this.waybillIdNums.length > 0) {
        // this.$router.push({
        //   name: "train",
        //   query: { type: "4", id: this.waybillIdNums }
        // });
        // console.log("======================");
        this.$router.push({
          name: "auditEdit",
          query: {
            mode: "add",
            audit_type: "3", //审计类型
            audit_carrier_id: this.waybillIdNums, //审计承运商
          },
        });
      } else {
      }
    },
    adduser(val) {
      if (val == "0") {
        this.ruleForm.account.push({
          user_name: "", // 账号
          password: "", // 密码
          mobile: "", //手机号
          nickname: "", // 昵称
          data_view_permission_type:"0",
          type_ids:[]
        });
      }
    },
    startoff(index, val) {
      if (val == "0") {
        this.ruleForm.account.splice(index, 1);
      }
    },
    // 检查用户名是否重复
    checkUser(rule, val, cb) {
      UserCount({ username: val }).then((res) => {
        if (res.data > 0) {
          cb(new Error("用户名已存在"));
        } else {
          cb();
        }
      });
    },
  },
};
</script>

<style lang="less" scoped>
::v-deep .business_license .el-upload-list {
  width: 180px;
}

.road_transport_data {
  min-height: 50px;
}

.shareContainer {
  padding: 10px 15px;
  background-color: #fff;

  .sharecontent_header_left {
    display: flex;
    justify-content: flex-end;
    margin: 10px 0px 0px 0px;
  }

  .shareheader {
    margin: 0 auto;

    .shareheader_top {
      display: flex;
      flex-wrap: wrap;
    }
  }

  // 内容
  .sharecontent {
    margin: 0 auto;
    background: white;

    // 头部内容
    .sharecontent_header {
      display: flex;
      justify-content: space-between;

      .sharecontent_header_right {
      }

      margin: 0px 0px 10px 0px;

      .sharecontent_header_left_left {
        display: flex;
      }
    }

    // 表单内容
    .sharecontent_content {
    }
  }
}
</style>